"""
API主入口
集成所有API路由
"""

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from api.role_play_api import router as role_play_router

# 创建FastAPI应用
app = FastAPI(
    title="AI角色扮演API",
    description="提供角色扮演和语音聊天功能的API",
    version="1.0.0"
)

# 添加CORS中间件
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # 允许所有来源
    allow_credentials=True,
    allow_methods=["*"],  # 允许所有方法
    allow_headers=["*"],  # 允许所有头
)

# 注册路由
app.include_router(role_play_router)

@app.get("/")
async def root():
    """API根路径"""
    return {
        "message": "欢迎使用AI角色扮演API",
        "docs_url": "/docs",
        "redoc_url": "/redoc"
    }

# 启动服务器代码
if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="localhost", port=8000)